﻿#include "socket_item.h"
#include <QPainter>
#include <QPointF>

SocketObject::SocketObject( QGraphicsItem *parent , QGraphicsTextItem *carNumberItem , QString *carIP)
    : QGraphicsItem(parent),
      carNumberItem(carNumberItem),
      carIP(carIP)
{  
    this->setAcceptedMouseButtons(Qt::LeftButton);
    //影响不大
    this->setFlag(QGraphicsItem::ItemIsSelectable,false);
    this->setZValue(-2);
    this->Color_0 = QColor(244, 96, 108);
    this->Color_1 = QColor(190, 237, 199);
    this->Color_2 = QColor(230, 206, 172);
    this->Color_3 = QColor(25, 202, 173);
    this->mysocketcolor = Color_0;
    this->isAtOringin = false;
    this->isMoving = false;
    this->isConnected = false;
};
SocketObject::~SocketObject()
{

}


QRectF SocketObject::boundingRect() const
{
    return QRectF(-15,-15,30,30);
}


void SocketObject::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(option);
    Q_UNUSED(widget);

    qreal circleRadius = 15;
    painter->setBrush(mysocketcolor);
    painter->drawEllipse(QPointF(0,0),circleRadius, circleRadius);
}

